package com.ruoyi.util.entinfo;


import com.ruoyi.common.core.domain.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class MessageUtil {
    private static final Logger logger = LoggerFactory.getLogger(MessageUtil.class);
    private static final String SN = "SDK-BHY-010-00072"; // 序列号
    private static final String PWD = "KKJW3ZgU"; // 序列号


    public static AjaxResult sendMsg(String mobiles, String code) throws UnsupportedEncodingException {
        String msg = "【病毒中心】验证码  {"+ code +"},您正在登录 国家计算机病毒应急处理中心 官网，有效期为5分钟 如非本人操作，请忽略。 ";
        String content= URLEncoder.encode(msg, "utf8");

        logger.info("发送手机号："+ mobiles+", 内容：" + msg);

        Client client=new Client(SN, PWD);
        String result_mt = client.mdSmsSend_u(mobiles, content, "", "", "");
        logger.info("发送结果："+ result_mt);
        if(result_mt.startsWith("-")||result_mt.equals("")) {
            return AjaxResult.error("发送失败！返回值为："+result_mt+"请查看webservice返回值对照表");
        }

        return AjaxResult.success(result_mt);
    }

}